<template>
  <div class="app-container">
    <div class="head">
      <img src="@/assets/img/Layout/position.png" />
      <p class="see-block">模版配置新建</p>
    </div>
    <div class="view-container">
      <el-row class="status-title">
        <el-col class="mr20 width100">
          <el-button
            class="btn-success width100"
            type="primary"
            @click="submitForm()"
          >提交</el-button>
        </el-col>
      </el-row>
      <el-form ref="form" :model="form" :rules="rules" label-width="150px" class="mt30">
        <el-row>
          <el-col :span="10">
            <el-form-item label="模板名称:" prop="templateName">
              <el-input v-model="form.templateName" placeholder="请输入模板名称" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="10">
            <el-form-item label="模板地址:" prop="templateAddress">
              <el-input v-model="form.templateAddress" placeholder="请输入模板地址" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
  </div>
</template>

<script>
import { antiCodeTemplateAdd } from "@/api/system/antiCode/antiCode"
export default {
  name: "add",
  data(){
    return {
      form: {
        templateName: '', // 模板名称
        templateAddress: '', // 模板地址
      },
      // 表单校验
      rules: {}
    }
  },
  methods: {
    // 提交数据
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.$modal.loading("正在提交")
          antiCodeTemplateAdd(this.form).then(res=> {
            if(res.code == 200){
              this.$tab.closeOpenPage({ path: "/antiCode/template/list" })
              this.$modal.msgSuccess("新建成功")
              this.$modal.closeLoading()
            }
          })
        }
      })
    }
  }
}
</script>